// 定时器
package main

import (
	app "gitee.com/go_888/xcgui/xcgui/app"
	font "gitee.com/go_888/xcgui/xcgui/font"
	widget "gitee.com/go_888/xcgui/xcgui/widget"
	window "gitee.com/go_888/xcgui/xcgui/window"
	xcc "gitee.com/go_888/xcgui/xcgui/xcc"
	"time"
)

var (
	a    *app.X结构_全局API
	w    *window.Window
	text *widget.X结构_形状文本
)

func main() {
	a = app.X创建(true)
	a.X启用DPI(true)
	a.X启用自动DPI(true)
	w = window.X创建窗口(0, 0, 500, 130, "定时器", 0, xcc.X窗口样式_默认样式)

	text = widget.X创建形状文本(50, 50, 400, 50, time.Now().Format("2006-01-02 15:04:05"), w.X句柄)
	text.X设置字体(font.X创建(30).X句柄)

	// 定时器id是自己定的
	w.X设置定时器(1, 1000)
	w.X事件_定时器(func(nIDEvent uint, pbHandled *bool) int {
		switch nIDEvent {
		case 1:
			text.X设置文本(time.Now().Format("2006-01-02 15:04:05"))
			text.X重绘()
		}
		return 0
	})

	w.X显示(true)
	a.X运行()
	a.X退出()
}
